import * as echarts from '../../components/ec-canvas/ec-canvas';
let chart1;



Page({
  data: {
    ec: {
      lazyLoad: true,//如果不需要进行动态获取数据进行加载，可以设置为false
    },

  },
     /**
   *初始化统计图，在动态获取数据后调用此方法
   */
  initEcharts: function() {
    var that = this;
    chart1.init((canvas, width, height) => {
      const chart1Model = echarts.init(canvas, null, {
        width: width,
        height: height
      });
      // 注意这里一定要返回 chart 实例，否则会影响事件处理等
      // OPTION可以从官网调整后复制到这里
      //以下为线图样例
      chart1Model.setOption({
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross'
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['4时', '5时', '6时', '7时', '8时', '9时', '10时', '11时', '12时', '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时', '21时', '22时']
        },
        yAxis: {
          type: 'value'
        },
        legend: {
          data: ['今日', '昨日'],
          show: true,
          left: 0,
          top: 10,
        },
        color: ['#3E5BB7', "#F07043"],
        series: [{
          name: '今日',
          data: [1, 2, 3, 10, 11, 12, 13, 14, 15, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50],
          type: 'line',
          smooth: true
        }, {
          name: '昨日',
          data: [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],
          type: 'line',
          smooth: true
        }]
      })
      return chart1Model;
    })
  },


  onLoad: function (options) {
    let that=this;
    setTimeout(() => {
      chart1 = that.selectComponent("#bottom-echarts-canvas");
    }, 3000);

  },
  onShow: function () {
     
  },
   
})